<%--
  User: naim
  Date: Dec 23, 2009
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="/c.tld" %>
<html>
<head>
    <title>DSE ALERT! :: Price List</title>
    <link href="<c:url value='/css/common.css'/>" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
    <meta http-equiv="refresh" content="600">
</head>
<body>


<div id="container">
<%@include file="/header.jsp"%>

    <c:if test="${!empty latestPrice}">
        <div style="text-align:right;padding-bottom:4px">
            <a href="#"
               onclick="popup('<c:url value="/stock/refreshPriceList"/>', 'Latest Price List');">
                Open in Auto-refresh mode
            </a>
            (every 5 minutes)
        </div>
    </c:if>

    <div id="page-header">
        Latest Price List
    </div>

    <c:choose>
        <%--@elvariable id="latestPrice" type="java.util.List"--%>
        <c:when test="${empty latestPrice}">
            <div class="msg">
                You have not yet subscribed to any item!
            </div>
        </c:when>
        <c:otherwise>
            <table width="100%">
                <c:forEach var="i" items="${latestPrice}">
                    <c:set var="className" value="data"/>
                    <c:choose>
                        <c:when test="${i.low || i.high}">
                            <c:set var="className" value="data-highlighted"/>
                        </c:when>
                    </c:choose>
                    <tr>
                        <td class="${className}">
                            <c:if test="${i.low}">
                                <img src="/images/down.gif" alt="Low!"/>
                            </c:if>
                            <c:if test="${i.high}">
                                <img src="/images/up.gif" alt="high!"/>
                            </c:if>
                            <a href="http://dsebd.org/displayCompany.php?name=${i.item}" target="_blank"><c:out value="${i.item}"/></a>
                        </td>
                        <td class="${className}">
                            <c:out value="${i.price}"/>
                            <c:if test="${not empty i.myPrice}">
                                <sub>(<c:out value="${i.myPrice}"/>)</sub>
                            </c:if> 
                        </td>
                        <td class="${className}">
                            <a href="<c:out value='/stock/priceHistory?item=${i.item}'/>">
                                Price History
                            </a>
                        </td>
                    </tr>
                </c:forEach>

                <tr>
                    <td colspan="3" align="center">
                        <c:if test="${!empty dateAndTime}">
                            <div class="small-msg">
                                <c:out value="${dateAndTime}"/>
                            </div>
                        </c:if>
                    </td>
                </tr>
            </table>
        </c:otherwise>
    </c:choose>

    <div style="text-align:center;font-size:12pt">
        <a href="<c:url value='/stock/items'/>">Subscribe to items</a>
    </div>

<%@ include file="/footer.jsp"%>
</div>

<script type="text/javascript">
    function popup(url, name) {
        var props = "toolbar=no,menubar=no,copyhistory=no,location=no,titlebar=no,scrollbars=yes,resizable=yes";
        var width = 300, height = 200;
        var sw = screen.width;
        var sh = screen.height;
        var x = sw / 2 - width / 2;
        var y = sh / 2 - height / 2;
        props = props + ",screenX=" + x + ",screenY=" + y + ",top=" + y + ",left=" + x
                + ",width=" + width + ",height=" + height;

        var popw = window.open(url, name, props);
        if (window.focus) {popw.focus()}
    }
</script>

</body>
</html>